#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int maxArea(vector<int>& height) {

        int back = 0;
        int front = height.size() - 1;

        int res = 0;

        while (back < front) {
            if (height[back] > height[front]) {
                res = max((front - back) * height[front], res);
                front--;
            }
            else {
                res = max((front - back) * height[back], res);
                back++;
            }
        }

        return res;
    }
};